/*
 *@res:SQL查询
 *@参数:param={
        url:url,//数据服务地址
        sql:sql,//查询条件
        layerName:layers.daoluLayer,//图层名称
        datalayerName:layers.datalayerName,
        callback:bindPage1//返回函数
    }
 **/
function _queryBySql(param) {
        var queryParam, queryBySQLParams, queryBySQLService;
        queryParam = new SuperMap.REST.FilterParameter({
            name: param.layerName,
            attributeFilter: param.sql
        });
        queryBySQLParams = new SuperMap.REST.GetFeaturesBySQLParameters({
        	queryParameter: queryParam,
 	         toIndex:-1,
 	         datasetNames: [param.datalayerName]
        });
        queryBySQLService = new SuperMap.REST.GetFeaturesBySQLService(param.url, {
        	eventListeners: {
                "processCompleted":function(queryEventArgs){
                    if(typeof(param.callback)==="function"){
                      param.callback(queryEventArgs);
                    }
                  }, 
                  "processFailed":_functionFailed
                }});
        queryBySQLService.processAsync(queryBySQLParams);
    };  
    //查询失败函数
    function _functionFailed(e) {
       // console.log("查询失败");
    }
/*
*@res:Geotry查询
*@参数:param={
      url:url,//数据服务地址
      sql:sql,//查询条件
      layerName:layers.daoluLayer,//图层名称
      datalayerName:layers.datalayerName,
      callback:bindPage1//返回函数
  }
**/
function queryByGeo(param){
	 var queryParam, queryByGeometryParameters, queryService;
         queryByGeometryParameters = new SuperMap.REST.GetFeaturesByGeometryParameters({
  	     datasetNames: [param.datalayerName],
         toIndex:-1,
         geometry: param.geo,
         spatialQueryMode: SuperMap.REST.SpatialQueryMode.INTERSECT
     });          
     queryService = new SuperMap.REST.GetFeaturesByGeometryService(param.url,{
     	eventListeners: {
            "processCompleted":function(queryEventArgs){
                if(typeof(param.callback)==="function"){
                  param.callback(queryEventArgs);
                }
              }, 
              "processFailed":_functionFailed
            }});
     queryService.processAsync(queryByGeometryParameters);
}
/*
*@缓冲区分析
*@author:杨怀涛
*参数:param={
      url:url,//数据服务地址
      sql:sql,//查询条件
      layerName:layers.daoluLayer,//图层名称
      datalayerName:layers.datalayerName,
      callback:bindPage1//返回函数
  }
**/
var bufferResultGeometry;
function  bufferAnalystProcess(param) {
	
    var bufferServiceByGeometry = new SuperMap.REST.BufferAnalystService(param.serverurlsys),
    bufferDistance = new SuperMap.REST.BufferDistance({
        value: param.distance
    }),
    filterParameter = new SuperMap.REST.FilterParameter({
        attributeFilter:param.sql
    }),
    bufferSetting = new SuperMap.REST.BufferSetting({
        endType: SuperMap.REST.BufferEndType.ROUND,
        leftDistance: bufferDistance,
        rightDistance: bufferDistance,
        semicircleLineSegment: 10
    }),
    geoBufferAnalystParam = new SuperMap.REST.DatasetBufferAnalystParameters({
    	dataset:  param.layerName,
        filterQueryParameter: filterParameter,
        bufferSetting: bufferSetting
    });

    bufferServiceByGeometry.events.on(
            {
                "processCompleted": function(queryEventArgs){
                    if(typeof(param.callback)==="function"){
                        param.callback(queryEventArgs);
                      }
                    }
            });
    bufferServiceByGeometry.processAsync(geoBufferAnalystParam);
}
function bufferAnalystCompleted(args) {
        bufferResultGeometry = args.result.recordset.features[0].geometry;
	    drawPointCompleted(bufferResultGeometry);
}